package com.myproject.thread.interrupt;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.locks.LockSupport;

public class Test {

    public static volatile boolean flag = true;
    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("start");
                LockSupport.park();
                System.out.println("end");
                while (true){

                }
            }
        });
        thread.start();
        try {
            thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        thread.interrupt();
        System.out.println("1 "+thread.isInterrupted());
        thread.interrupt();
        System.out.println("2 "+thread.isInterrupted());

        /*LockSupport.unpark(thread);
        System.out.println("1 "+thread.isInterrupted());
        LockSupport.unpark(thread);
        System.out.println("2 "+thread.isInterrupted());*/

    }
}
